home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 66
/
Vol 66.iso
/
games
/
bob_espo.swf
/
scripts
/
__Packages
/
MiniGames
/
BTW
/
BTWBall.as
< prev
next >
Wrap
Text File
|
2013-04-24
|
3KB
|
92 lines
class MiniGames.BTW.BTWBall extends State
{
static var sSTATE_MOVE = "Move";
static var sSTATE_EXPLODE = "Explode";
static var sSTATE_DESTROYED = "Destroyed";
static var sLINKAGE_BALL = "SB_ASP_IceBall";
var nSPEED = 2;
static var nCOUNTER = 0;
static var nNB_SPLASH_SOUNDS = 5;
static var nSPLASH_VOLUME = 100;
function BTWBall(_mcParent, _oWallTarget, _nX, _nY)
{
super(_mcParent.attachMovie(MiniGames.BTW.BTWBall.sLINKAGE_BALL,"mcBall" + ++MiniGames.BTW.BTWBall.nCOUNTER,_mcParent.getNextHighestDepth()));
this.mcRef._x = _nX;
this.mcRef._y = _nY;
this.isExplodingOnce = false;
this.setState(MiniGames.BTW.BTWBall.sSTATE_MOVE);
this.oWallTarget = _oWallTarget;
var _loc7_ = this.mcRef._x - this.oWallTarget.mcRef._x;
var _loc8_ = this.mcRef._y - this.oWallTarget.mcRef._y;
var _loc9_ = _loc8_ / _loc7_;
this.nSPEED = 5 / 30 * _loc7_;
this.nX = this.nSPEED;
this.nY = _loc9_ * this.nSPEED;
if(_loc7_ > _loc8_)
{
_loc9_ = _loc7_ / _loc8_;
this.nSPEED = 5 / 30 * _loc8_;
this.nX = _loc9_ * this.nSPEED;
this.nY = this.nSPEED;
}
this.setState(MiniGames.BTW.BTWBall.sSTATE_MOVE);
}
function cleanUp()
{
this.mcRef.removeMovieClip();
}
function isDestroyed()
{
var _loc2_ = false;
if(this.sState == MiniGames.BTW.BTWBall.sSTATE_DESTROYED)
{
_loc2_ = true;
}
return _loc2_;
}
function isExploding()
{
var _loc2_ = false;
if(this.sState == MiniGames.BTW.BTWBall.sSTATE_EXPLODE && this.isExplodingOnce == false)
{
_loc2_ = true;
this.isExplodingOnce = true;
}
return _loc2_;
}
function get Target()
{
return this.oWallTarget;
}
function Move()
{
if(!Controller.getRef().isPaused())
{
this.mcRef._x -= this.nX;
this.mcRef._y -= this.nY;
if(this.mcRef._x <= this.oWallTarget.mcRef._x && this.mcRef._y <= this.oWallTarget.mcRef._y)
{
if(!this.oWallTarget.isDestroyed())
{
this.setState(MiniGames.BTW.BTWBall.sSTATE_EXPLODE);
Controller.getRef().getSounds().playRandomSound(MiniGames.BTW.BTWBall.nNB_SPLASH_SOUNDS,"IceBall_Splashed",MiniGames.BTW.BTWBall.nSPLASH_VOLUME);
}
else
{
this.setState(MiniGames.BTW.BTWBall.sSTATE_DESTROYED);
}
}
}
}
function Explode()
{
if(this.stateFinished())
{
this.setState(MiniGames.BTW.BTWBall.sSTATE_DESTROYED);
}
}
function Destroyed()
{
}
}